<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/myordermain.css" media="all">
<script type="text/javascript" src="__PUBLIC__/js/jquery1.8.3.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/dialog.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/wei_webapp_v2_common.js"></script>
<title>{$metaTitle}</title>
<!--meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"-->
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="Keywords" content="">
<meta name="Description" content="">
<!-- Mobile Devices Support @begin -->
	<meta content="telephone=no, address=no" name="format-detection">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<!-- apple devices fullscreen -->
	<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<!-- Mobile Devices Support @end -->
</head>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/home.css" media="all">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/wei_canyin.css" media="all" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/order-index.css">
<style type="text/css">
.my_menu_list th{color: #7C7C7C;}
.box li{margin-left:15px;}
#list td{padding-left:15px;}
.headselect a{color:#fff;}
#reorderBox {
	background-color: rgb(121,45,0);
	padding: 15px 8px;
	margin: 0px 8px;
	text-align: center;
}
#reorderBtn {
	color: white;
	font-size: medium;
}
</style>
<style type="text/css">
</style>
<body id="page_intelOrder" class="myOrderCon">
		<!--header class="nav" id="nav1" style="margin:0px;padding-bottom: 7px;">
			<div>
				<--a href="javascript:;" class="on">菜单</a>
				<a href="{:U('Wap/OrderFood/myOrder')}">我的订单</a->
				<img src="__PUBLIC__/images/calendar.png"><span class="nav-date">{$today}</span>
			</div>
	
		</header>
		<div  class="basket-area" style="position:absolute;right:5px;top:10px;text-align:center; color:white;font-size:18px;">
			<img src="__PUBLIC__/images/basket1.png" style="width:20px; height:20px;">
			<a href="{:U('Wap/OrderFood/myOrder')}"><span style="color: white;">{$basketid}</span></a>
			
		</div-->
	<!--header class="nav" style="margin:0px">
		<div>
			
			<a href="{:U('Wap/OrderFood/index')}">菜单</a>
			<a href="javascript:;" class="on">我的订单</a>
		</div>
	</header-->
	<div id="muhead">
		<div id="head-background">
			<!--img id="header-background-image" src="__PUBLIC__/images/header-background_01.jpg"-->
			<img id="header-background-image" src="https://img.yzcdn.cn/upload_files/2015/07/09/FrWLc31WQcdNyIUAHP7k5I_thofQ.jpg">
			<div id="mu-nav">
			</div>
			<div id="mu-menu">
				<span style="padding: 0% 1.5%;"></span>
				<img id="mu-logo" src="__PUBLIC__/images/9mu-logo-02.png">
				<!--img src="https://img.yzcdn.cn/upload_files/2015/07/09/Fk1GU7hK59H9cPnNfd1WMoTnaQgh.jpg?imageView2/2/w/200/h/200/q/75/format/jpg" style="width: 72px; height: 72px;"-->
				<span class="mu-menu-list">
					<ul class="mu-menu-ul">
						<li class="zmenu">{$today}</li> 
						<li class="zemnu img"><img src="__PUBLIC__/images/seprate.png"></li>
						<li class="zmenu">菜篮子:<span id="basketid">{$basketid}</span></li>
						<li class="zemnu img"><img src="__PUBLIC__/images/seprate.png"></li>
						<li class="zmenu"><a href="{:U('Wap/OrderFood/myOrder')}">我的订单</a></li>
					</ul>
				</span>
			</div>
		</div>
	</div>
<div class="container">
	<ul class="box">
		<li>
			<a href="javascript:void(0);" id="addresBtn">
				<strong>
					<span id="showAddres"><if condition="$userinfo['address']">{$userinfo['address']}<else/>请点击添加送餐地址</if></span><br>
					<span id="showName"><if condition="$userinfo['truename']">{$userinfo['truename']}</if></span>
					<span id="showTel"><if condition="$userinfo['tell']">{$userinfo['tell']}</if></span>
					</strong>
				<div><i class="ico_arrow"></i></div>
			</a>
		</li>
	</ul>
	<if condition="$cancel_status == 1">
	<div id="reorderBox">
			<a href="{:U('Wap/OrderFood/reOrder')}" id="reorderBtn">
				当期重新下单
			</a>
	</div>
	</if>
<header id="container">
	<div style="padding:10px 0;">
		<ul class="list_order" id='list' style="color:#181818;font-size:16px">
		 <if condition="!empty($orderList)">
			<volist name="orderList" id="order">
				<li>
				<label style="float:none;color:#666666;font-size: 15px;" onclick="this.classList.toggle('on');">
					下单日：{$order['addtime']|date="Y-m-d",###} <br/>
					配送时间：下单日的{$order['postTime']}<br/>
					订单状态：<if condition="$order['state']==1">未配送<elseif condition="$order['state']==2"/>已配送<elseif condition="$order['state']==3"/>已送达</if>
				</label>
				
				<ol>
				<div>
				<if condition="$canOrder eq true AND $curPeriodid eq $order['oopid']">
				<a class="comm_btn" style="float:right;" href="{:U('Wap/OrderFood/index', array('orderid' => $order['orderid']))}">修改订单</a>
				</if>
				</div>
				<table class="my_menu_list">
				<thead>
					<tr>
						<th style="padding-left: 17px;">菜品列表</th>
						<th style="padding-right: 20px;">{$order['goodTotal']}份</th>
						<!--th style="padding-right: 32px;"><strong class="highlight">￥{$order['price']}</strong></th-->
					</tr>
				</thead>
				<tbody>
				 <volist name="order['info']" id="cgood" key="k1">
				 <volist name="cgood" id="good" key="k">
				  <tr>
					<td>{$good['name']}</td>
					<td style="width: 60px;">X{$good['num']}</td>
					<!--td style="width: 90px;">￥{$ditem['price']}</td-->
				  </tr>
				  </volist>
				 </volist>
				</tbody>
			</table>

			<ul class="box">
				<li>点菜人：{$order['truename']}</li>
				<li>手机：{$order['tell']}</li>
				<li>配送地址：{$order['address']}</li>
				<li>配送时间：下单日{$order['addtime']|date="Y-m-d",###}{$order['postTime']}</li>
				<li>支付方式：会费预缴</li>
				<if condition="$order['postcode'] neq null"><li>快递单号:{$order['postcode']}</li></if>
			</ul>
			<ul class="box">
				<li>备注</li>
				<li><if condition="empty($order['mark'])">
				无
				<else/>
				{$order['mark']}
				</if>
				</li>
			</ul>
			</ol>
			</li>
		 </volist>
		 <else/>
	     <li>您还没有任何订单信息</li>
		 </if>
		</ul>
	</div>
</header>
</div>
<div class="addres_box" id="addresBox">
	  <ul>
		<input type="hidden" id="openid" name="openid" value="{$userinfo['openid']}">
		<input class="hidden" type="hidden" id="ouserSex" name="ouserSex" <if condition="$userinfo['sex']">value="{$userinfo['sex']}"<else/>value="0"</if> >
		<li><input class="txt" placeholder="预定人" id="userName"></li>
		<li class="get_code">
			<span><input class="txt" placeholder="手机" maxlength="11" id="userTel"></span>
		</li>
		<li class="get_code" style="display:none;">
			<span>性别：<label><input type="radio" name="yousex" id="yousex1" value="1" checked="checked" class="sexinput"> 男 </label>
			&nbsp;&nbsp;&nbsp;
			<label><input type="radio" name="yousex" id="yousex0" value="0" class="sexinput"> 女 </label></span>
		</li>
		<li><textarea class="txt" placeholder="送餐地址" id="userAddres"></textarea></li>
		<li class="btns_wrap">
			<span><a href="javascript:void(0);" class="comm_btn higher disabled" id="cancleAddres">取消</a></span>
			<span><a href="javascript:void(0);" class="comm_btn higher" id="saveAddres">确认</a></span>
		</li>
	</ul>
</div>
<script>
var updateAdressUrl = "{:U('Wap/OrderFood/updateAddress')}";
var addressBox = {
	init: function(){
		this.differTime = 60;
		this.box = $('#addresBox');
		this.errorMsg = {
			userName: '预定人不能为空',
			userTel: '手机不能为空',
			userAddres: '送餐地址不能为空'
		};

		var _this = this;
		$('#addresBtn').click(function(){
			_this.show.call(this, _this);
		});
		$('#saveAddres').click(function(){
			_this.save.call(this, _this);
		});
		$('#cancleAddres').click(function(){
			_this.close();
		});
	},
	show: function(obj){ /**obj是_this**$(this)是$('#addresBtn')***/
		var addressTxt = $.trim($(this).find('strong').text());
		if(addressTxt == '' || addressTxt == '请点击添加送餐地址'){
			
		}else{
			var sex=$.trim($('#ouserSex').val());
			sex=parseInt(sex);
			if(sex==0){
			  $('#yousex0').click();
			}else{
			  $('#yousex1').click();
			}
			$('#userName').val($('#showName').text());
			$('#userTel').val($('#showTel').text());
			$('#userAddres').val($('#showAddres').text());
		}

		obj.box.dialog({title: '送餐地址', closeCb: function(){
			obj.reset();
		}});
	},
	save: function(obj){
		var error = '',
			tel = $('#userTel').val();
		$('#userName, #userTel, #userAddres').each(function(){
			if(this.value == ''){
				error += obj.errorMsg[this.id] + '\n';
			}
		});

		function fillData(){
			$('#showAddres').text($('#userAddres').val());
			$('#showName').text($('#userName').val());
			$('#showTel').text(tel);

			obj.close();
		}

		// 判断是否为空
		if(error){
			alert(error);
			return false;
		}
		if(!/^.{5,20}$/gi.test(tel) || !/^(\+\s?)?(\d*\s?)?(?:\(\s?(\d+[-\s])?\d+\s?\)\s?)?\s?(\d+[-\s]?)+\d+$/gi.test(tel)){
				alert('请输入正确的手机号码');
				return false
		}
		fillData();
		
		// 发起ajax更新
		var openid = $("#openid").val();
		var username = $("#userName").val();
		var tel = $("#userTel").val();
		var sex = $("#ouserSex").val();
		var addr = $("#userAddres").val();
		
		$.ajax({
			url: updateAdressUrl,
			type: 'POST',
			asyn:true,
			data:{
				openid:openid,
				username:username,
				tel:tel,
				sex:sex,
				addr:addr,
			},
			timeout: 10000,
			dataType:'json',
			success:function(data, textStatus, jsqXHR) {
				
			},
			error:function(data, textStatus) {
				alert("更新地址失败");
			},
		});
	},
	reset: function(){
		$('#codeWrap').hide();
		$('#userTel').attr('disabled', false);
		$('#userCode').val('');
	},
	close:function(){
		this.box.dialog('close');
		this.reset();
	}
};
$('#addresBox .sexinput').bind('click', function(){
		var vsex=$(this).val();
		$('#ouserSex').val(vsex);
});

$(function(){
	addressBox.init();
});
</script>
<script>
$(document).ready(function(){
    var min_height = $(document).height()-300;
    $("#container").css({"min-height":min_height});
});

</script>
</body>
</html>